# -*- coding: utf-8 -*-
"""
Created on Thu May 26 14:44:29 2022

@author: zhao
"""

from scipy.special import lpmv # associated Legendre function
import numpy as np
import matplotlib.pyplot as plt
import scienceplots
x=np.linspace(-1,1,1000)
plt.style.use('science') # 这个需要单独安装
plt.figure(1,dpi=300)
m=4  # m degree
for v in range(m, m+3): # v is the order
    plt.plot(x,lpmv(m,v,x) ,linewidth = '0.7',label='$l$='+str(v)) 

plt.plot(x,np.zeros(1000),linewidth = '0.1',color='black') 
plt.title('associated-Legendre polynomials')
plt.xlabel('x')
plt.ylabel(f'$P^m_l(x)$,  $m=${m}')
#plt.legend(loc='upper right')
plt.legend()
name=f'associated-Legendre-l-m={m}.png'

plt.savefig(name,dpi=300)
plt.show() 